/**
 * @author Maximilian Csuk
 * @author Konrad Paumann
 * @author Bernhard Denner
 */

public class MyFloat extends Number {
	private float value;
	
	public MyFloat(float value) {
		this.value = value;
	}
	
	/**
	 * Returns the value of the stored number
	 */
	public float getValue() {
		return value;
	}
	
	/**
	 * Returns the result of the evaluation 
	 * which is the instance of the actual number.
	 */
	public Number eval() {
		return this;
	}
	
	/**
	 * Adds that number to this number if this and that are instances of 
	 * the same class and returns the result
	 * Otherwise a new instance of NotaNumber is returned
	 */
	public Number add(Number that) {
		if (this.getClass() == that.getClass()) {
			return new MyFloat(((MyFloat)that).value + value);
		}
		return new NotaNumber();
	}
	
	/**
	 * Multiplies this number with that number if this and that are instances of 
	 * the same class and returns the result
	 * Otherwise a new instance of NotaNumber is returned
	 */
	public Number mul(Number that) {
		if (this.getClass() == that.getClass()) {
			return new MyFloat(((MyFloat)that).value * value);
		}
		return new NotaNumber();
	}
	
	/**
	 * Truncates this number and returns the result
	 */
	public Number trunc() {
		return new MyInteger((int)value);
	}
	
	/**
	 * Returns the string representation
	 */
	public String toString() {
		return Float.toString(value);
	}
	
}
